﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;

namespace Zero.UControl.Component
{
    public class TitleAttachHelper
    {
        #region Title（标题信息）

        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.RegisterAttached(
                "Title",
                typeof(object),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetTitle(DependencyObject element, object value) =>
            element.SetValue(TitleProperty, value);

        public static object GetTitle(DependencyObject element) =>
            element.GetValue(TitleProperty);


        public static Brush GetTitleForeground(DependencyObject obj)
        {
            return (Brush)obj.GetValue(TitleForegroundProperty);
        }

        public static void SetTitleForeground(DependencyObject obj, Brush value)
        {
            obj.SetValue(TitleForegroundProperty, value);
        }

        public static readonly DependencyProperty TitleForegroundProperty =
            DependencyProperty.RegisterAttached("TitleForeground", typeof(Brush), typeof(TitleAttachHelper),
                new PropertyMetadata(new SolidColorBrush(Colors.Black)));


        public static Brush GetTitleBackground(DependencyObject obj)
        {
            return (Brush)obj.GetValue(TitleBackgroundProperty);
        }

        public static void SetTitleBackground(DependencyObject obj, Brush value)
        {
            obj.SetValue(TitleBackgroundProperty, value);
        }

        public static readonly DependencyProperty TitleBackgroundProperty =
            DependencyProperty.RegisterAttached("TitleBackground", typeof(Brush), typeof(TitleAttachHelper),
                new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));

        #endregion

        #region Background（标题背景色）

        public static readonly DependencyProperty BackgroundProperty =
            DependencyProperty.RegisterAttached(
                "Background",
                typeof(Brush),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetBackground(DependencyObject element, Brush value) =>
            element.SetValue(BackgroundProperty, value);

        public static Brush GetBackground(DependencyObject element) =>
            (Brush)element.GetValue(BackgroundProperty);

        #endregion

        #region Foreground（标题字体色）

        public static readonly DependencyProperty ForegroundProperty =
            DependencyProperty.RegisterAttached(
                "Foreground",
                typeof(Brush),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetForeground(DependencyObject element, Brush value) =>
            element.SetValue(ForegroundProperty, value);

        public static Brush GetForeground(DependencyObject element) =>
            (Brush)element.GetValue(ForegroundProperty);

        #endregion

        #region BorderBrush（标题边框色）

        public static readonly DependencyProperty BorderBrushProperty =
            DependencyProperty.RegisterAttached(
                "BorderBrush",
                typeof(Brush),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetBorderBrush(DependencyObject element, Brush value) =>
            element.SetValue(BorderBrushProperty, value);

        public static Brush GetBorderBrush(DependencyObject element) =>
            (Brush)element.GetValue(BorderBrushProperty);

        #endregion

        #region TitlePlacement（标题对齐方式）

        public static readonly DependencyProperty TitlePlacementProperty =
            DependencyProperty.RegisterAttached(
                "TitlePlacement",
                typeof(Dock),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(Dock.Left, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetTitlePlacement(DependencyObject element, Dock value) =>
            element.SetValue(TitlePlacementProperty, value);

        public static Dock GetTitlePlacement(DependencyObject element) =>
            (Dock)element.GetValue(TitlePlacementProperty);

        #endregion

        #region TitleWidth（标题宽度）

        public static readonly DependencyProperty TitleWidthProperty =
            DependencyProperty.RegisterAttached(
                "TitleWidth",
                typeof(double),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(double.NaN, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetTitleWidth(DependencyObject element, double value) =>
            element.SetValue(TitleWidthProperty, value);

        public static double GetTitleWidth(DependencyObject element) =>
            (double)element.GetValue(TitleWidthProperty);

        #endregion

        #region Placeholder（输入占位提示）

        public static readonly DependencyProperty PlaceholderProperty =
            DependencyProperty.RegisterAttached(
                "Placeholder",
                typeof(string),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetPlaceholder(DependencyObject element, string value) =>
            element.SetValue(PlaceholderProperty, value);

        public static string GetPlaceholder(DependencyObject element) =>
            (string)element.GetValue(PlaceholderProperty);

        #endregion

        #region Necessary（是否必填）

        public static readonly DependencyProperty NecessaryProperty =
            DependencyProperty.RegisterAttached(
                "Necessary",
                typeof(bool),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetNecessary(DependencyObject element, bool value) =>
            element.SetValue(NecessaryProperty, value);

        public static bool GetNecessary(DependencyObject element) =>
            (bool)element.GetValue(NecessaryProperty);

        #endregion

        #region Symbol（标记信息）

        public static readonly DependencyProperty SymbolProperty =
            DependencyProperty.RegisterAttached(
                "Symbol",
                typeof(string),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata("*", FrameworkPropertyMetadataOptions.Inherits));

        public static void SetSymbol(DependencyObject element, object value) =>
            element.SetValue(SymbolProperty, value);

        public static object GetSymbol(DependencyObject element) =>
            element.GetValue(SymbolProperty);

        #endregion

        #region ContentHeight（内容高度）

        public static readonly DependencyProperty ContentHeightProperty =
            DependencyProperty.RegisterAttached(
                "ContentHeight",
                typeof(double),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(double.NaN, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetContentHeight(DependencyObject element, double value) =>
            element.SetValue(ContentHeightProperty, value);

        public static double GetContentHeight(DependencyObject element) =>
            (double)element.GetValue(ContentHeightProperty);

        #endregion

        #region MinContentHeight

        public static readonly DependencyProperty MinContentHeightProperty =
            DependencyProperty.RegisterAttached(
                "MinContentHeight",
                typeof(double),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetMinContentHeight(DependencyObject element, double value) =>
            element.SetValue(MinContentHeightProperty, value);

        public static double GetMinContentHeight(DependencyObject element) =>
            (double)element.GetValue(MinContentHeightProperty);

        #endregion

        #region MaxContentHeight

        public static readonly DependencyProperty MaxContentHeightProperty =
            DependencyProperty.RegisterAttached(
                "MaxContentHeight",
                typeof(double),
                typeof(TitleAttachHelper),
                new FrameworkPropertyMetadata(double.PositiveInfinity, FrameworkPropertyMetadataOptions.Inherits));

        public static void SetMaxContentHeight(DependencyObject element, double value) =>
            element.SetValue(MaxContentHeightProperty, value);

        public static double GetMaxContentHeight(DependencyObject element) =>
            (double)element.GetValue(MaxContentHeightProperty);

        #endregion
    }
}
